/*
 * addon.h
 *
 *  Created on: 2010-1-7
 *      Author: gavinkwoe
 */

#ifndef ADDON_GRAPHICS_H_
#define ADDON_GRAPHICS_H_

#include "addon_features.h"
#include "addon_std.h"
#include "addon_objbase.h"

/*************************************************************************
* MACRO
*************************************************************************/

#define	ADDON_TEXT_ALIGN_LEFT		(0)
#define	ADDON_TEXT_ALIGN_CENTER		(1)
#define	ADDON_TEXT_ALIGN_RIGHT		(2)

/*************************************************************************
* INTERFACE
*************************************************************************/

ADDON_INTERFACE_( IAddonCanvas, 1, IObject )
{
	__INHERIT_FROM( IObject )

	ADDON_METHOD( Attach )			( ADDON_REF(IObject) thiz, IN void * handle );
	ADDON_METHOD( DrawText )		( ADDON_REF(IObject) thiz, IN unsigned short * text, IN unsigned long text_len, IN addon_rect_ptr_t rc, IN unsigned long align );
	ADDON_METHOD( DrawTextVertT2D )	( ADDON_REF(IObject) thiz, IN unsigned short * text, IN unsigned long text_len, IN addon_rect_ptr_t rc, IN unsigned long align );
	ADDON_METHOD( DrawTextVertD2T )	( ADDON_REF(IObject) thiz, IN unsigned short * text, IN unsigned long text_len, IN addon_rect_ptr_t rc, IN unsigned long align );
};
 
ADDON_INTERFACE_( IAddonFont, 1, IObject )
{
	__INHERIT_FROM( IObject )

	ADDON_METHOD( Attach )				( ADDON_REF(IObject) thiz, IN void * handle );
	ADDON_METHOD( GetHeight )			( ADDON_REF(IObject) thiz, OUT unsigned long * pheight );
	ADDON_METHOD( GetCharWidth )		( ADDON_REF(IObject) thiz, IN unsigned short chr, OUT unsigned long * pwidth );
	ADDON_METHOD( CountCharInWidthR )	( ADDON_REF(IObject) thiz, IN unsigned short * buff, IN unsigned long off, IN unsigned long max_width,
											OUT unsigned long * pwidth, OUT unsigned long * char_cnt );
	ADDON_METHOD( CountCharInWidth )	( ADDON_REF(IObject) thiz, IN unsigned short * buff, IN unsigned long size, IN unsigned long max_width,
											OUT unsigned long * pwidth, OUT unsigned long * char_cnt );
	ADDON_METHOD( Recache )				( ADDON_REF(IObject) thiz );
};

/*************************************************************************
* DECLARATION
*************************************************************************/

#if defined(__cplusplus)
extern "C" {
#endif	// #if defined(__cplusplus)

ADDON_IMPORT ADDON_REF(IObject)	addon_create_canvas( void * reserved );
ADDON_IMPORT ADDON_REF(IObject)	addon_create_font( void * reserved );

#if defined(__cplusplus)
}
#endif	// #if defined(__cplusplus)

/*************************************************************************
* MACRO
*************************************************************************/

#define IAddonCanvas_VTBL( p )							ADDON_GET_VTBL_(p, IAddonCanvas)
#define IAddonCanvas_CALL( p, a )						IAddonCanvas_VTBL(p)->a
#define IAddonCanvas_Attach( p, a )						IAddonCanvas_CALL( p, Attach )( p, a )
#define IAddonCanvas_DrawText( p, a, b, c, d )			IAddonCanvas_CALL( p, DrawText )( p, a, b, c, d )
#define IAddonCanvas_DrawTextVertT2D( p, a, b, c, d )	IAddonCanvas_CALL( p, DrawTextVertT2D )( p, a, b, c, d )
#define IAddonCanvas_DrawTextVertD2T( p, a, b, c, d )	IAddonCanvas_CALL( p, DrawTextVertD2T )( p, a, b, c, d )

#define IAddonFont_VTBL( p )					ADDON_GET_VTBL_(p, IAddonFont)
#define IAddonFont_CALL( p, a )					IAddonFont_VTBL(p)->a
#define IAddonFont_Attach( p, a )				IAddonFont_CALL( p, Attach )( p, a )
#define IAddonFont_GetHeight( p, a )			IAddonFont_CALL( p, GetHeight )( p, a )
#define IAddonFont_GetCharWidth( p, a, b )		IAddonFont_CALL( p, GetCharWidth )( p, a, b)
#define IAddonFont_CountCharInWidthR( p , a, b, c, d, e ) \
		IAddonFont_CALL( p, CountCharInWidthR )( p, a, b, c, d, e )
#define IAddonFont_CountCharInWidth( p , a, b, c, d, e ) \
		IAddonFont_CALL( p, CountCharInWidth )( p, a, b, c, d, e )
#define IAddonFont_Recache( p )					IAddonFont_CALL( p, Recache )( p )

#endif /* ADDON_GRAPHICS_H_ */
